package com.sino.struts2;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.sino.business.IExpertManageService;
import com.sino.business.IStaticDataService;
import com.sino.business.service.LoginInfo;
import com.sino.model.ExpertAndPatentModel;
import com.sino.model.ExpertModel;
import com.sino.model.ZhuanyemaModel;
import com.sino.util.CreatQueryCondition;
import com.sino.util.PageControl;
import com.sino.util.SysParameter;

public class ExpertAssignAction extends ActionSupport {
	private IExpertManageService expertManageServiceImp;

	private IStaticDataService staticDateService;// 基础数据

	private List expertandbasicinfoList;

	private List expertAndBasicinfoList;

	private List expertReviewList;

	private ExpertAndPatentModel eapm;

	private ExpertModel expertModel;

	private List basicInfoList;

	private List xkList;

	private String page = "1";// 当前页

	private String pageStr;// 分页字符串

	private String qxkwTitle;

	private List expertList;// 专家列表

	private List smList; // 项目列表

	private String zlid;

	private String fbh;

	private String fBh[];

	private String zjxm[];

	private int pageRow;

	private String mode;

	private List<ZhuanyemaModel> xkzlList;

	private String zhuanye = "";

	private String zhuanye1 = "";

	public String getZhuanye1() {
		return zhuanye1;
	}

	public void setZhuanye1(String zhuanye1) {
		this.zhuanye1 = zhuanye1;
	}

	public String getAssignExpertList() {
		expertandbasicinfoList = this.getExpertManageServiceImp()
				.getExpertsAndBasicinfoByZlid(zlid);
		return SUCCESS;
	}

	public String getExpertByZhuanye() {
		xkzlList = this.getStaticDateService().findZhuanyema();
		expertList = this.getExpertManageServiceImp().findAllExperts();
		return SUCCESS;
	}
	
	public String getExpertByZhuanye1() {
		xkzlList = this.getStaticDateService().findZhuanyema();
		if (!"".equals(zhuanye) && !"all".equals(zhuanye)) {
			expertList = this.getExpertManageServiceImp()
					.findExpertByZhuanyema(zhuanye);
		} else if ("".equals(zhuanye) || null == zhuanye
				|| "all".equals(zhuanye)) {
			expertList = this.getExpertManageServiceImp().findAllExperts();
		}
		return SUCCESS;
	}

	// xyw 项目
	public String getSmByZhuanye() {
		String hqlWhere = "year=" + SysParameter.CURRENT_YEAR;
		xkzlList = this.getStaticDateService().findZhuanyema();
		expertList = this.getExpertManageServiceImp().findAllSms(hqlWhere);
		return SUCCESS;
	}
	
	public String getSmByZhuanye1() {
		String hqlWhere = "year=" + SysParameter.CURRENT_YEAR;
		xkzlList = this.getStaticDateService().findZhuanyema();
		if (!"".equals(zhuanye1) && !"all".equals(zhuanye1)) {
			expertList = this.getExpertManageServiceImp().findSmByZhuanyema(
					hqlWhere, zhuanye1);
		} else if ("".equals(zhuanye1) || null == zhuanye1
				|| "all".equals(zhuanye1)) {
			expertList = this.getExpertManageServiceImp().findAllSms(hqlWhere);
		}
		return SUCCESS;
	}

	// xyw 高级查找
	public String findSmList() {
		HttpServletRequest request = ServletActionContext.getRequest();
		CreatQueryCondition creatQueryCondition = new CreatQueryCondition();// 条件查询类
		creatQueryCondition.initializtion(request);// 初始化查询条件
		expertList = this.getExpertManageServiceImp().findSms(
				creatQueryCondition.getHqlWhere());
		xkzlList = this.getStaticDateService().findZhuanyema();
		return SUCCESS;
	}

	public String findExpertList() {
		HttpServletRequest request = ServletActionContext.getRequest();
		CreatQueryCondition creatQueryCondition = new CreatQueryCondition();// 条件查询类
		creatQueryCondition.initializtion(request);// 初始化查询条件
		expertList = this.getExpertManageServiceImp().findExperts(
				creatQueryCondition.getHqlWhere());
		xkzlList = this.getStaticDateService().findZhuanyema();
		return SUCCESS;
	}

	public String getBasicinfoOfAssignExpert() {
		Map session = ActionContext.getContext().getSession();
		LoginInfo logininfo = (LoginInfo) session.get("logininfo");
		String qxkw = logininfo.getQxkw();
		HttpServletRequest request = ServletActionContext.getRequest();
		PageControl pageControl = new PageControl();// 翻页控制类
		CreatQueryCondition creatQueryCondition = new CreatQueryCondition();// 条件查询类
		creatQueryCondition.initializtion(request);// 初始化查询条件
		pageControl.setPage(page);// 设置当前页
		pageControl.setPageSize(3);// 设置每页显示的记录数量
		pageControl.setRowCount(this.getExpertManageServiceImp()
				.getReviewPatentPageCount(creatQueryCondition.getHqlWhere(),
						mode));// 设置总记录数
		int startRow = (pageControl.getPage() - 1) * pageControl.getPageSize();// 开始行数
		int pageSize = pageControl.getPageSize();// 每页显示的数量
		pageStr = pageControl.getPageInfo(
				"getBasicinfoOfAssignExpert.action?mode=notAssign",
				creatQueryCondition.getCondition());
		basicInfoList = this.getExpertManageServiceImp()
				.getReviewPatentPageList(startRow, pageSize,
						creatQueryCondition.getHqlWhere(), mode);// 分页查询考生信息
		qxkwTitle = "北京市发明专利基本信息列表";
		this.setPageStr(pageStr);
		this.setPageRow(startRow);
		return SUCCESS;
	}

	public String selectAssignExpertList() {
		HttpServletRequest request = ServletActionContext.getRequest();
		PageControl pageControl = new PageControl();// 翻页控制类
		CreatQueryCondition creatQueryCondition = new CreatQueryCondition();// 条件查询类
		creatQueryCondition.initializtion(request);// 初始化查询条件
		pageControl.setPage(page);// 设置当前页
		pageControl.setPageSize(50);// 设置每页显示的记录数量
		pageControl.setRowCount(this.getExpertManageServiceImp()
				.getExpertsCount(creatQueryCondition.getHqlWhere()));// 设置总记录数
		int startRow = (pageControl.getPage() - 1) * pageControl.getPageSize();// 开始行数
		int pageSize = pageControl.getPageSize();// 每页显示的数量
		pageStr = pageControl.getPageInfo(
				"selectAssignExpertList.action?method=expertList",
				creatQueryCondition.getCondition());
		expertAndBasicinfoList = this.getExpertManageServiceImp()
				.getExpertsAndBasicinfoByZlid(zlid);
		expertList = this.getExpertManageServiceImp().getExpertList(startRow,
				pageSize, creatQueryCondition.getHqlWhere());// 分页查询考生信息
		xkList = staticDateService.findXkList();// 专家专业表
		this.setPageStr(pageStr);
		return SUCCESS;
	}

	public String saveExpertAndBasicinfo() {

		this.getExpertManageServiceImp().saveExpertAndBasicinfo(zlid, fBh);
		return SUCCESS;
	}

	public String disExpertAction() {
		expertModel = this.getExpertManageServiceImp().getExpertsByZlid(fbh);
		return SUCCESS;
	}

	// 取消专家
	public String canselReviewExpert() {
		this.getExpertManageServiceImp().delExpertAndBasicinfo(zlid);
		return SUCCESS;
	}

	// ------------------------------------set 和 get 方法
	public List getExpertandbasicinfoList() {
		return expertandbasicinfoList;
	}

	public void setExpertandbasicinfoList(List expertandbasicinfoList) {
		this.expertandbasicinfoList = expertandbasicinfoList;
	}

	public List getExpertList() {
		return expertList;
	}

	public void setExpertList(List expertList) {
		this.expertList = expertList;
	}

	public List getBasicInfoList() {
		return basicInfoList;
	}

	public void setBasicInfoList(List basicInfoList) {
		this.basicInfoList = basicInfoList;
	}

	public String getPage() {
		return page;
	}

	public void setPage(String page) {
		this.page = page;
	}

	public String getPageStr() {
		return pageStr;
	}

	public void setPageStr(String pageStr) {
		this.pageStr = pageStr;
	}

	public String getQxkwTitle() {
		return qxkwTitle;
	}

	public void setQxkwTitle(String qxkwTitle) {
		this.qxkwTitle = qxkwTitle;
	}

	public IExpertManageService getExpertManageServiceImp() {
		return expertManageServiceImp;
	}

	public void setExpertManageServiceImp(
			IExpertManageService expertManageServiceImp) {
		this.expertManageServiceImp = expertManageServiceImp;
	}

	public String getZlid() {
		return zlid;
	}

	public void setZlid(String zlid) {
		this.zlid = zlid;
	}

	public ExpertAndPatentModel getEapm() {
		return eapm;
	}

	public void setEapm(ExpertAndPatentModel eapm) {
		this.eapm = eapm;
	}

	public String getFbh() {
		return fbh;
	}

	public void setFbh(String fbh) {
		this.fbh = fbh;
	}

	public int getPageRow() {
		return pageRow;
	}

	public void setPageRow(int pageRow) {
		this.pageRow = pageRow;
	}

	public String[] getZjxm() {
		return zjxm;
	}

	public void setZjxm(String[] zjxm) {
		this.zjxm = zjxm;
	}

	public List getExpertAndBasicinfoList() {
		return expertAndBasicinfoList;
	}

	public void setExpertAndBasicinfoList(List expertAndBasicinfoList) {
		this.expertAndBasicinfoList = expertAndBasicinfoList;
	}

	public String[] getFBh() {
		return fBh;
	}

	public void setFBh(String[] bh) {
		fBh = bh;
	}

	public ExpertModel getExpertModel() {
		return expertModel;
	}

	public void setExpertModel(ExpertModel expertModel) {
		this.expertModel = expertModel;
	}

	public void setExpertReviewList(List expertReviewList) {
		this.expertReviewList = expertReviewList;
	}

	public String getMode() {
		return mode;
	}

	public void setMode(String mode) {
		this.mode = mode;
	}

	public IStaticDataService getStaticDateService() {
		return staticDateService;
	}

	public void setStaticDateService(IStaticDataService staticDateService) {
		this.staticDateService = staticDateService;
	}

	public List getExpertReviewList() {
		return expertReviewList;
	}

	public List getXkList() {
		return xkList;
	}

	public void setXkList(List xkList) {
		this.xkList = xkList;
	}

	public List<ZhuanyemaModel> getXkzlList() {
		return xkzlList;
	}

	public void setXkzlList(List<ZhuanyemaModel> xkzlList) {
		this.xkzlList = xkzlList;
	}

	/**
	 * @return the zhuanye
	 */
	public String getZhuanye() {
		return zhuanye;
	}

	/**
	 * @param zhuanye
	 *            the zhuanye to set
	 */
	public void setZhuanye(String zhuanye) {
		this.zhuanye = zhuanye;
	}

	public List getSmList() {
		return smList;
	}

	public void setSmList(List smList) {
		this.smList = smList;
	}

}
